<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,role-scalable=no" />
	<title>修改工艺</title>
	<link rel="stylesheet" type="text/css" href="/admin/layui/css/layui.css" />
	<link rel="stylesheet" type="text/css" href="/admin/css/admin.css" />
</head>
<body>
<div class="wrap-container">
	<form class="layui-form" lay-filter="edit-crafts" style="width: 90%;padding-top: 20px;">
		<div class="layui-form-item">
			<label class="layui-form-label">工艺编号：</label>
			<div class="layui-input-block">
				<input type="text" name="craftsCode" required lay-verify="required" placeholder="请输入工艺编号" autocomplete="off" class="layui-input">
			</div>

		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">工艺描述：</label>
			<div class="layui-input-block">
				<input type="text" name="craftsDesc" required lay-verify="required" placeholder="请输入工艺描述" autocomplete="off" class="layui-input">
			</div>

		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">所属站点：</label>
			<div class="layui-input-block">
				<input type="text" name="site" required lay-verify="required" placeholder="所属站点..." autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">创建人：</label>
			<div class="layui-input-block">
				<input type="text" name="createBy" required lay-verify="required" placeholder="创建人..." autocomplete="off" class="layui-input">
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">工艺类型：</label>
			<div class="layui-input-block">
				<input type="radio" name="craftsType" value="0" title="标准工艺" checked>
				<input type="radio" name="craftsType" value="1" title="专业工艺">
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn layui-btn-normal" lay-submit lay-filter="editCrafts">立即提交</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>
</div>

<script src="/admin/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script>
	layui.use(['form'], function() {
		var form = layui.form;
		form.render();
		$ = layui.jquery;

		form.val("edit-crafts",parent.editCrafts);
		// 给表单赋值
		form.val("edit-crafts", { //formTest 即 class="layui-form" 所在元素属性 lay-filter="" 对应的值
			"craftsCode": parent.editCrafts.craftsCode // "name": "value"
			,"craftsDesc": parent.editCrafts.craftsDesc // "name": "value"
			,"site": parent.editCrafts.site
			,"createBy": parent.editCrafts.createBy
			,"craftsType": parent.editCrafts.craftsType
		});

		//获取表单区域所有值

		//监听提交
		form.on('submit(editCrafts)', function(data) {
			var craftsData = form.val("edit-crafts");
			craftsData.craftsId = parent.editCrafts.craftsId;
			$.ajax({
				type: "post",
				data: craftsData,
				url: "http://localhost:8080/crafts/updateCrafts",
				error: function (XMLHttpRequest, textStatus, errorThrown) {
					alert("系统异常，请联系管理员!");
				},
				success: function (data) {
					layer.alert(data.message, {
						skin: 'layui-layer-molv' //样式类名  自定义样式
						, closeBtn: 1    // 是否显示关闭按钮
						, anim: 1 //动画类型
						, icon: 6    // icon
					});
					active.reload();
				}
			});
			return false;
		});
	});
</script>
</body>

</html>